perm filename FAKE12.SAI[DOC,TOB] blob
sn#234927 filedate 1976-08-31 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00007 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002
C00004 00003
C00008 00004
C00009 00005
C00010 00006 SECOND_LOOP:
C00012 00007 for a range of conf values, and corresponding diff values, find
C00014 ENDMK
C⊗;
comment
this version has only the loop for finding the
min step for 50% detection of edges, with 1%
false positives on zero height edges;
BEGIN "EDGE_TEST"
comment
find best choice of conf and diff for Hueckel edge
operator based on chosen false positive rate for
no signal. For a given false positive rate, find
choice which requires the least height step to
achieve a 50% false negative rate. This uses
steps generated by a Monte Carlo procedure;
DEFINE SAFE_ARRAY=1; comment this makes all arrays safe;
REQUIRE "VISION.2[SYS,TOB]" SOURCE_FILE; comment vision language package;
REQUIRE EDGE_FILE;
REQUIRE EDGE_PRINT;
REQUIRE TV_VARIABLES;
REQUIRE "STEP4.SAI[FAK,TOB]" SOURCE_FILE;
comment
conf=sqrt(s0sq/(s0sq+n0sq)) ie cosine
diff=s0sq;
BOOLEAN SIMPLE PROCEDURE YES(STRING S);
BEGIN "YES"
S←ASK_STRING(S);
IF EQU(S,"Y")∨EQU(S,"y")∨EQU(S,"YES")∨EQU(S,"yes")
THEN RETURN (1) ELSE RETURN (0);
END "YES";
DEFINE NBHD=8; comment the size of the array with fake intensity values;
LABEL FIRST_LOOP; ! entry for false positives and others;
LABEL SECOND_LOOP; ! entry for false negatives;
LABEL ERR_TEST; ! entry for angular and position errors;
LABEL FALSE_NEG; ! entry for false negatives;
LABEL AVG_DIFF; ! entry for avg value of diff;
LABEL HISTO_LOOP; ! loop entry for histograms repeat with change scale;
DEFINE MAX_COUNT=2000; ! the max number of test samples generated;
INTEGER_ARRAY INTENSITY[1:NBHD*NBHD]; ! store fake intensities here;
REAL_ARRAY N0SQA[1:MAX_COUNT+20]; ! store n0sq from edge oper here;
REAL_ARRAY S0SQA[1:MAX_COUNT+20] ; ! store s0sq from edge oper here;
INTEGER_ARRAY COUNT[0:100]; ! histogram of scaled s0sq values;
SHORT INTEGER K,K1;
INTEGER ENOUGH; ! how many samples (< max_count);
SHORT REAL STEP_MEAN,STEP_AMPLITUDE,NOISE_STD;
comment the mean,amplitude,noise of fake steps;
SHORT REAL NSQ; ! scaling factor which depends on noise squared;
SHORT REAL NOISE_SCALE; ! scaling factor for histograms;
SHORT REAL THETA,RHO; ! angle,perp dist of edge from origin;
SHORT INTEGER BYTES; ! number of bytes per word;
SHORT REAL LAMBDA; ! wavelength (used to get phase near an edge);
SHORT INTEGER N1,N5,KN1,KN5; comment 1% and 5% level counts and indices;
ENOUGH←MAX_COUNT;
comment now init the edge operator;
CONF←.05;DIFF←.05; ! choose low values to reject nothing;
BITS←6;
MODIFY(BITS);
LINLEN←WORDS(NBHD,BITS);
TVWORD←GIOWD(INTENSITY);
LSIDE←1;RSIDE←NBHD;
FLINE←1;LLINE←NBHD;
EJINIT;
DIFF←0;CONF←.05;
comment set up values for fake edges with zero height;
NOISE_STD←5.0; ! amplitude of gaussian noise;
STEP_MEAN←(2↑BITS-1)*.5; ! offset to get positive intensities;
STEP_AMPLITUDE←0; ! step height for fake edges;
NOISE_SCALE←20.0;
SECOND_LOOP:
BEGIN "MIN_STEP"
LABEL TEST_LOOP;
LABEL MIN_REPEAT;
REAL STEP_FRACTION;
INTEGER KQ;
INTEGER PRINT_FLAG;
PRELOAD_WITH 1.250,1.350,1.350,1.400,1.400,1.400,1.400,1.400,1.400,1.400,
1.400,1.400,1.400;
OWN REAL ARRAY DIFF_CUTOFF[1:20]; ! cutoffs for diff;
PRINT_FLAG←1;
MODIFY(PRINT_FLAG);
MODIFY(NOISE_STD);
NSQ←NOISE_STD↑2;
STEP_FRACTION←1.0;
MODIFY(ENOUGH); ! ask user if he wants another value;
MODIFY(THETA);
MODIFY(RHO);
IF ENOUGH>MAX_COUNT THEN ENOUGH←MAX_COUNT;
MIN_REPEAT:
MODIFY(STEP_FRACTION);
STEP_AMPLITUDE←NOISE_STD*STEP_FRACTION;
PRINT(STEP_AMPLITUDE);
OUTSTR(CRLF&"FALSE NEGATIVES ");
FOR K1←1 STEP 20 UNTIL ENOUGH DO BEGIN "ACCUM1"
FOR K←K1 STEP 1 UNTIL K1+20 DO BEGIN "ACCUM" ! report every 20 events;
SHORT INTEGER N;
LABEL CALLFK;
CALLFK: FAKE(NBHD,NBHD,THETA,RHO,LAMBDA,
STEP_MEAN,STEP_AMPLITUDE,NOISE_STD,NOISE,INTENSITY);
comment generate an array with zero edge,random;
EJLI(NBHD/2,NBHD/2,0,0); ! try the edge operator on it;
N0SQA[K]←N0SQ; ! save the noise squared;
S0SQA[K]←S0SQ; ! and save the signal squared;
END "ACCUM";
PRINT(K);
END "ACCUM1";
comment for a range of conf values, and corresponding diff values, find
number of rejections of fake edges;
TEST_LOOP:
KQ←0;
FOR CONF←.95 STEP -.05 UNTIL .40 DO BEGIN "CONF_LOOP" ! loop over conf;
SHORT REAL CONFSQ;
SHORT INTEGER N;
KQ←KQ+1;
N1←0;
CONFSQ←CONF↑2;
FOR K←1 STEP 1 UNTIL ENOUGH DO BEGIN "ACCUM"
SHORT REAL S;
S←S0SQA[K];
IF S/(S+N0SQA[K])>CONFSQ THEN BEGIN ! if above conf;
IF S>DIFF_CUTOFF[KQ]*NSQ THEN N1←N1+1
ELSE IF PRINT_FLAG THEN OUTSTR(CRLF&CVG(S));
END;
END "ACCUM";
TCRLF;
PRINT(CONF);OUTSTR(" "&CVG(DIFF_CUTOFF[KQ]*NSQ));
OUTSTR(" "&CVG(DIFF_CUTOFF[KQ]));
PRINT(ENOUGH)PRINT(N1);
INCHWL;
END "CONF_LOOP";
IF EQU(ASK_STRING(CRLF&"REPEAT HISTOGRAMS "),"Y") THEN GO TO TEST_LOOP;
END "MIN_STEP";
IF EQU(ASK_STRING(CRLF&"REPEAT VALUES"),"Y") THEN GO TO SECOND_LOOP;
END "EDGE_TEST";